package com.tzbank.back.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tzbank.back.dao.RoleAuthMapper;
import com.tzbank.back.service.RoleAuthService;
import com.tzbank.entity.backstage.RoleAuth;
import com.tzbank.utils.CodeUtil;
import com.tzbank.utils.ResultUtil;

@Service
public class RoleAuthServiceImpl implements RoleAuthService {

	@Autowired
	private RoleAuthMapper roleAuthMapper;

	@Transactional
	@Override
	public Map<String, Object> deleteRoleAuth(RoleAuth roleAuth) throws Exception{
		this.roleAuthMapper.deleteRoleAuth(roleAuth);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), null);
	}

	@Transactional
	@Override
	public Map<String, Object> insertRoleAuth(RoleAuth roleAuth) throws Exception {
		this.roleAuthMapper.insertRoleAuth(roleAuth);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), null);
	}

	@Override
	public Map<String, Object> selectRoleAuthByAutoId(int autoId) throws Exception{
		RoleAuth roleAuth = this.roleAuthMapper.selectRoleAuthByAutoId(autoId);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), roleAuth);
	}

	@Override
	public Map<String, Object> selectRoleAuthList() throws Exception{
		List<RoleAuth> roleAuths = this.roleAuthMapper.selectRoleAuthList();
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), roleAuths);
	}

	@Transactional
	@Override
	public Map<String, Object> updateRoleAuth(RoleAuth roleAuth) throws Exception{
		this.roleAuthMapper.updateRoleAuth(roleAuth);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), null);
	}

}
